<?php

require_once 'init.php';

$do = cf\param::get('do');

switch ($do) {
	case 'add':
		$imgId = cf\api\admin\doAction('add_tmp_item_image',array('image'=>''));
		$imagePath = cf\query2var('SELECT image FROM tmp_item_images WHERE id=:id',array('id'=>$imgId));
		break;
		
	case 'cancel':
		$IDs = cf\param::get('id');
		array_walk($IDs,function(&$v,$k) { $v = array('id'=>$v); });
		cf\api\admin\doDelete('del_tmp_item_image', $IDs);
		break;
		
	case 'save':
		$IDs = cf\param::get('id');
		array_walk($IDs,function(&$v,$k) { $v = array('id'=>$v); });
		cf\api\admin\doActionBulk('del_tmp_item_image', $IDs);
		break;
}
?>

<html>
<body>

<script>
	window.image_id = '<?=$imgId?>';
	window.image_path = '<?=$imagePath?>';
</script>

</body>
</html>